<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!-- 兼容性 -->
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <title>计划督导-督导工作记录</title>
    <script src="/scripts/boot.js"></script>
    <style>
        html,body{
            margin:0;padding: 0;border:0;width:100%;height:100%;overflow:hidden;
        }
        body{
            background: #ffffff!important;
            padding:20px;
        }
    </style>
</head>
<body>
<div class="title-list mb-20"><span class="title-listbg"></span><span>督导工作记录</span></div>
<div id="qForm"  class="mini-toolbar1" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
        <tr>
            <td style="width:100%;">
                <div class="mb-20 position-rel">
                    <span class="search-title search-ml20">项目名称</span><select id="itemId" name="itemId" class="mini-combobox w200" ajaxType="post" url="/item/list" emptyText="全部" showNullItem="true" nullItemText="全部" textField="name" valueField="id"></select>
                    <!--<span class="search-title search-ml60">选择年月</span><div id="yearItem"></div>-->
                    <!--<span class="search-title search-ml60">选择年月</span><input id="date1" allowInput="false" class="mini-monthpicker search-200px"/>-->
                    <a class="add-botton search-ml60" onclick="list.search()">查询</a>
                    <a class="resetting-btn search-ml20" onclick="list.reset()">重置</a>
                </div>
            </td>
        </tr>
    </table>
</div>
<div class="mini-fit">
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;"  url="/supervise/problem/listRecordByPage" sizeList="[5,10,20,50]" pageSize="20"  idField="user_id" multiSelect="true" showEmptyText="true" emptyText="暂无数据" alwaysShowEmptyText="true">
        <div property="columns">
            <div type="indexcolumn" headerAlign="center" width="30" align="center">编号</div>
            <div field="itemName" width="120" headerAlign="center" allowSort="false">项目名称</div>
            <div field="planName" width="120" headerAlign="center" allowSort="false">计划名称</div>
            <div field="planType" width="120" headerAlign="center" align="center" allowSort="false">计划类型</div>
            <div field="beginEndDate" width="120" headerAlign="center" align="center" allowSort="false" renderer="ondayRenderer">计划起止时间</div>
            <div field="createDate" width="120" headerAlign="center" align="center" allowSort="false" renderer="ondayRenderer">督导时间</div>
            <div field="status" width="120" headerAlign="center" align="center" allowSort="false">状态</div>
            <div name="action" width="160" headerAlign="center" align="center" allowSort="false">操作</div>
        </div>
    </div>
</div>
<script type="text/javascript">
    //list.init();
    var grid;
    var list = {
        //页面初始化
        init: function() {
            mini.parse();
            // common.changeYears();
            grid = mini.get("datagrid1");
            grid.load();
            mini.get("datagrid1").on("drawcell", function (e) {
                var column = e.column;
                if(column.field=="itemName"){
                    e.cellHtml = e.row.itemName?e.row.itemName:e.row.planName;
                }
                if(column.field=="status"){
                    if(e.row.status==0){
                        e.cellHtml = "未上报";
                    }else if(e.row.status==1){
                        e.cellHtml = "已上报";
                    }
                }
                if(column.field=="beginEndDate"){
                    var dateText = "";
                    if(e.row.beginDate&&e.row.endDate){
                        dateText="至"
                    }
                    e.cellHtml = (e.row.beginDate?e.row.beginDate.substring(0,10):"")+dateText+(e.row.endDate?e.row.endDate.substring(0,10):"");
                }
                if (column.name == "action") {
                    if(e.row.status==0){
                        e.cellHtml = '<a class="revise-botton" href="javascript:list.edit()">编辑</a>'+
                        '<a class="del-botton btn-bd" href="javascript:list.remove()">删除</a>';
                    }else {
                        e.cellHtml = '<a class="check-botton" href="javascript:list.view()">详情</a>';
                    }
                }
            })
        },
        //填报记录
        edit: function(){
            mini.open({
                url: "/planSupervision/logging/supervisor.html",
                title: "修改督导信息", width: 1100, height: 900,
                onload: function () {
                    var row = grid.getSelected();
                    // var id = row.id.substr(0,row.id.lastIndexOf("@"));
                    var state=row.riskState==1?"有风险":"失控";
                    var data = {"id": row.id,"nodeName":row.nodeName,'postName':row.postName,'state':state};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        //督导记录
        view: function(){
            mini.open({
                url: "/planSupervision/logging/view.html",
                title: "督导记录", width: 1100, height: 900,
                onload: function () {
                    var row = grid.getSelected();
                    var data = {"id": row.id};
                    var iframe = this.getIFrameEl();
                    iframe.contentWindow.view.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        },
        remove:function(){
            var row = grid.getSelected();
            if (row) {
                mini.confirm("确定删除选中记录？","确定",function (action) {
                	debugger
                    if(action=="ok"){
                        $.ajax({
                            url: "/supervise/problem/del",
                            type : "post",
                            data:{"id":row.id},
                            success: function (text) {
                                if (text.state) {
                                    grid.reload();
                                } else {
                                    mini.showMessageBox({
                                        showModal: false,
                                        width: 250,
                                        title: "提示",
                                        iconCls: "mini-messagebox-warning",
                                        message: text.message,
                                    });

                                }
                            }
                        });
                    }
                });
            } else {
                alert("请选中一条记录");
            }
        },
        //    查询
        search: function () {
            var data = {
                "itemId": mini.get("itemId").getValue()
            };
            grid.load(data);
        },
     
        //重置
        reset:function(){
            var form = new mini.Form("qForm");
            form.reset();
            grid.load()
        }
    };
    list.init();
</script>
</body>
</html>